home *** CD-ROM | disk | FTP | other *** search
/ Champak 125 / Vol 125 (Damaged).iso / games / rabbit_r.swf / scripts / __Packages / disney / rabbitRivalry / ui / UI.as < prev    next >
Encoding:
Text File  |  2009-06-09  |  3.6 KB  |  128 lines

  1. class disney.rabbitRivalry.ui.UI
  2. {
  3.    var engine;
  4.    var __nextScreenID;
  5.    var __hasActiveScreen;
  6.    var __doesActiveScreenUpdate;
  7.    var __hasIntroPlayed;
  8.    var __activeScreen;
  9.    var __previousScreenID;
  10.    var __activeScreenID;
  11.    static var __instance;
  12.    function UI()
  13.    {
  14.    }
  15.    static function init()
  16.    {
  17.       disney.rabbitRivalry.ui.UI.__instance = new disney.rabbitRivalry.ui.UI();
  18.    }
  19.    static function getInstance()
  20.    {
  21.       return disney.rabbitRivalry.ui.UI.__instance;
  22.    }
  23.    function linkEngine(t_engine)
  24.    {
  25.       this.engine = t_engine;
  26.       smashing.keithm.Messenger.registerAddress("ui",this);
  27.    }
  28.    function reset()
  29.    {
  30.       this.__nextScreenID = "";
  31.       this.__hasActiveScreen = false;
  32.       this.__doesActiveScreenUpdate = false;
  33.       this.__hasIntroPlayed = false;
  34.    }
  35.    function update(dt)
  36.    {
  37.       if(this.__doesActiveScreenUpdate)
  38.       {
  39.          this.__activeScreen.update(dt);
  40.       }
  41.    }
  42.    function returnToPreviousScreen()
  43.    {
  44.       this.__nextScreenID = this.__previousScreenID;
  45.       this.__activeScreen.close();
  46.    }
  47.    function goScreen(id)
  48.    {
  49.       if(this.__hasActiveScreen)
  50.       {
  51.          this.__nextScreenID = id;
  52.          this.__activeScreen.close();
  53.       }
  54.       else
  55.       {
  56.          this.openScreen(id);
  57.       }
  58.    }
  59.    function openScreen(id)
  60.    {
  61.       if(id == undefined)
  62.       {
  63.          id = this.__nextScreenID;
  64.       }
  65.       if(id == "")
  66.       {
  67.          return undefined;
  68.       }
  69.       this.__nextScreenID = "";
  70.       this.__previousScreenID = this.__activeScreenID;
  71.       this.__activeScreenID = id;
  72.       this.engine.gotoAndStop(this.__activeScreenID);
  73.       switch(this.__activeScreenID)
  74.       {
  75.          case "splash":
  76.             this.__activeScreen = new disney.rabbitRivalry.ui.Splash(this.engine.screen_mc,this,this.__hasIntroPlayed);
  77.             this.__hasIntroPlayed = true;
  78.             break;
  79.          case "gameplay":
  80.             this.__activeScreen = new disney.rabbitRivalry.ui.GamePlay(this.engine.screen_mc,this,this.engine.overlay_mc,this.engine.nav_mc,this.engine.helpPopup_mc);
  81.             break;
  82.          case "help":
  83.             this.__activeScreen = new disney.rabbitRivalry.ui.Help(this.engine.screen_mc,this);
  84.             break;
  85.          case "winLevel":
  86.             this.__activeScreen = new disney.rabbitRivalry.ui.WinLevel(this.engine.screen_mc,this);
  87.             break;
  88.          case "winGame":
  89.             this.__activeScreen = new disney.rabbitRivalry.ui.WinGame(this.engine.screen_mc,this);
  90.             break;
  91.          case "gameOver":
  92.             this.__activeScreen = new disney.rabbitRivalry.ui.GameOver(this.engine.screen_mc,this);
  93.             break;
  94.          default:
  95.             trace("[UI] openScreen called with invalid id: " + this.__activeScreenID);
  96.             return undefined;
  97.       }
  98.       this.__activeScreen.init();
  99.       this.__activeScreen.open();
  100.       smashing.keithm.Messenger.registerAddress("screen",this.__activeScreen);
  101.       this.__hasActiveScreen = true;
  102.       this.__doesActiveScreenUpdate = this.__activeScreen.DOES_UPDATE;
  103.    }
  104.    function onScreenClosed()
  105.    {
  106.       if(this.__nextScreenID != "")
  107.       {
  108.          this.openScreen(this.__nextScreenID);
  109.       }
  110.    }
  111.    function disableActiveScreenUpdates()
  112.    {
  113.       this.__doesActiveScreenUpdate = false;
  114.    }
  115.    function enableActiveScreenUpdates()
  116.    {
  117.       this.__doesActiveScreenUpdate = true;
  118.    }
  119.    function onMessageReceived(message, args)
  120.    {
  121.       this[message](args);
  122.    }
  123.    function get currentScreenID()
  124.    {
  125.       return this.__activeScreenID;
  126.    }
  127. }
  128.